<?php
require_once './component/head.php';
require_once './component/drawer.php';
if(isset($_COOKIE['Token'])) {
    require_once './function/conn.php';
    $info=AutoLoginCheck($_COOKIE['Token']);
    if ($info != 'none') LoginInit($info);
}
if (isset($_SESSION['uid'])) echo "<script type='text/javascript'>location.href='./center.php'</script>";
?>
    <script type="text/javascript">
        window.onload = function () {
            LoginOnload();
        };
    </script>

    <div class="mdui-container" id="page-login">
        <div class="mdui-row" id="login_card">
            <div class="mdui-card mdui-center">
                <!-- 卡片头部，包含头像、标题、副标题 -->
                <div class="mdui-card-header">
                    <img class="mdui-card-header-avatar" alt="头像" src="./src/img/picture.jpg"/>
                    <div class="mdui-card-header-title">用户</div>
                    <div class="mdui-card-header-subtitle">user</div>
                </div>
                <!-- 卡片的媒体内容，可以包含图片、视频等媒体内容，以及标题、副标题 -->
                <div class="mdui-card-media">
                    <img src="./src/img/img_login.jpg" alt="登录" height="200"/>
                </div>
                <!-- 卡片的内容 -->
                <div class="mdui-card-content">请使用电子邮件、密码登录访问。</div>
                <div class="mdui-divider"></div>
                <form action="function/function.php" method="post">
                    <div class="mdui-row">
                        <div class="mdui-col-xs-11">
                            <div class="mdui-textfield mdui-textfield-floating-label">
                                <i class="mdui-icon material-icons">account_circle</i>
                                <label class="mdui-textfield-label">电子邮件</label>
                                <input class="mdui-textfield-input" name="login_email" type="text"
                                       required="required"/>
                            </div>
                        </div>
                    </div>
                    <div class="mdui-row">
                        <div class="mdui-col-xs-11">
                            <div class="mdui-textfield mdui-textfield-floating-label">
                                <i class="mdui-icon material-icons">lock</i>
                                <label class="mdui-textfield-label">用户密码</label>
                                <input class="mdui-textfield-input" name="login_pwd" type="password"
                                       required="required"/>
                            </div>
                        </div>
                    </div>
                    <br/>
                    <div class="mdui-divider"></div>
                    <div class="mdui-card-actions">
                        <a onclick="ShowRegisterCard()" class="mdui-typo-body-1 mdui-btn mdui-ripple mdui-float-left">注册账号</a>
                        <label class="mdui-checkbox">
                            <input type="checkbox" value="yes" name="auto_login_checkbox"/>
                            <i class="mdui-checkbox-icon"></i>
                            自动登录
                        </label>
                        <button name="login_btn"
                                class="mdui-btn mdui-btn-raised mdui-ripple mdui-float-right mdui-color-theme-accent">
                            登录
                        </button>
                    </div>
                </form>
            </div>
        </div>

        <div class="mdui-row" id="register_card" style="display: none">
            <div class="mdui-card mdui-center">
                <!-- 卡片头部，包含头像、标题、副标题 -->
                <div class="mdui-card-header">
                    <img class="mdui-card-header-avatar" alt="头像" src="./src/img/picture.jpg"/>
                    <div class="mdui-card-header-title">新用户</div>
                    <div class="mdui-card-header-subtitle">new user</div>
                </div>
                <!-- 卡片的媒体内容，可以包含图片、视频等媒体内容，以及标题、副标题 -->
                <div class="mdui-card-media">
                    <img src="./src/img/img_register.jpg" alt="图片" height="200"/>
                </div>
                <!-- 卡片的内容 -->
                <div class="mdui-card-content">请输入电子邮件、密码注册。</div>
                <div class="mdui-divider"></div>
                <form action="function/function.php" method="post">
                    <div class="mdui-row">
                        <div class="mdui-col-xs-11">
                            <div class="mdui-textfield mdui-textfield-floating-label">
                                <i class="mdui-icon material-icons">account_circle</i>
                                <label class="mdui-textfield-label">Email</label>
                                <input class="mdui-textfield-input" name="register_email" type="email" required/>
                            </div>
                        </div>
                    </div>
                    <div class="mdui-row">
                        <div class="mdui-col-xs-11">
                            <div class="mdui-textfield mdui-textfield-floating-label">
                                <i class="mdui-icon material-icons">lock</i>
                                <label class="mdui-textfield-label">Password</label>
                                <input class="mdui-textfield-input" name="register_pwd" type="text"
                                       pattern="^.{6,20}$" required/>
                                <div class="mdui-textfield-helper">请输入6~20位的密码</div>
                            </div>
                        </div>
                    </div>
                    <br/>
                    <div class="mdui-divider"></div>
                    <!-- 卡片的按钮 -->
                    <div class="mdui-card-actions">
                        <a onclick="ShowLoginCard()"
                           class="mdui-typo-body-1 mdui-btn mdui-ripple mdui-float-left">已有账号？去登录！</a>
                        <button name="register_btn"
                                class="mdui-btn mdui-btn-raised mdui-ripple mdui-float-right  mdui-color-theme-accent">
                            注册
                        </button>
                    </div>
                </form>
            </div>
        </div>
    </div>

<?php require_once './component/footer.php'; ?>